/**
 * 
 */
	function loaddata(){
		var allFlag = $("#allFlag").val();
		var pno = $("#pagenum").val();
		var month=$("#month").val();
		var bonus=$("#bonus").val();
		var ope_fk=$("#ope_id").val();
		var score = $("#score").val();
		var emp_id = $("#emp_id").val();
		var classType = $("#classType").val();
		var url = pms_url + "cell/performance/list";
		var params = {month:month,bonus:bonus,ope_fk:ope_fk,score:score,emp_id:emp_id,classType:classType,pno:pno,allFlag:allFlag};
		var obj = load(url,params);//发送请求去服务端ope_fk数据	
		var ary = obj.performance;
		$("#performancelist").find("tbody").html("");
		$.each(ary, function(index, p) {
		var tr ="<tr role='row'>"+
		"<td>"+(index+1)+"</td>"+
		"<td>"+p.ope_name+"</td>"+
		"<td>"+p.emp_id+"</td>"+
		"<td>"+p.emp_name+"</td>"+
		"<td>"+p.gender+"</td>"+
		"<td>"+((p.bonus==null)?"0":p.bonus)+"</td>"+
		"<td>"+((p.attendance==null)?"0":p.attendance)+"</td>"+
		"<td>"+((p.operation==null)?"0":p.operation)+"</td>"+
		"<td>"+((p.specialty==null)?"0":p.specialty)+"</td>"+
		"<td>"+((p.audit==null)?"0":p.audit)+"</td>"+
		"<td>"+((p.discipline==null)?"0":p.discipline)+"</td>"+
		"<td>"+((p.compatibility==null)?"0":p.compatibility)+"</td>"+
		"<td>"+p.score+"</td></tr>";
		$("#performancelist").find("tbody").append(tr);
	 });
		
		//加载平均奖金
		
		var aurl = pms_url + "cell/performance/getAverageBouns";
		var param = {month:month,ope_fk:ope_fk,classType:classType};
		$.ajax({  
	        type : "post",  
	        url : aurl,  
	        data : param,
	        dataType : "json", 
	        async : false,  //同步
	        success : function(data){  
	           data = eval(data);  
		   		if (data.err_msg=="success") {
		   			$("#average").html(data.result);
				}
				else {
					alert("error");
				}
	        }  
	    });
	}

	
	
	$(function () {
		
		
		loaddata();
		//TableDatatablesEditable.init();
		
		
		//查询
		$('#btnSearch').on('click', function () {
			$("#pagenum").val(1);
			loaddata();
			
		});
		
		//重置
		$("#btnReset").on('click', function () {
			$("#searchform input").val("");
			$("#searchform select").val("");
		});	
	
		//更新
		$("#btnSyschron").on('click', function () {
			var url = pms_url + "cell/performance/syschron"; 
			var param = {};
			$.ajax({  
		        type : "post",  
		        url : url,  
		        dataType: "json", 
		        data : param, 
		        async : false,  //同步
		        beforeSend: function () {  
	        	        // 禁用按钮防止重复提交  
	        	        $("#btnSyschron").attr({ disabled: "disabled" });
	        	        MaskUtil.mask("正在更新中..."); 
	        	        
	        	    },  
		        success : function(data){ 
		    			if(data.err_msg=="success"){
		    				MaskUtil.unmask();
		    				alert("更新数据成功！");
		    		}
		        	},
		        complete: function () {  
		            	$("#btnSyschron").removeAttr("disabled");  
		            	MaskUtil.unmask();   
		            },  
            	error: function (data) {  
            	        console.info("error: " + data.responseText);  
            	    } 
		        });
		});	
		
		//导出
		$("#btnExport").on('click', function () {
			$("#performancelist").tableExport({
			    headings: true, 
			    footers: true, 
			    formats: ["xls"],
			    fileName: "data",
			    bootstrap: true,
			    position: "bottom",
			    ignoreRows: null,
			    ignoreCols: null
			});   

		});	
		
	});
	
	
//	var TableDatatablesEditable=
//		function(){
//		var e=function(){
//			var a=$("#performancelist"),
//			l=a.dataTable({lengthMenu:[[10,15,20,-1],[10,15,20,"All"]],pageLength:10,language:{lengthMenu:" _MENU_ records"},columnDefs:[{orderable:!0,targets:[0]},{searchable:!0,targets:[0]}],order:[[0,"asc"]]});
//			};
//								
//			return{init:function(){e()}}}();